package com.zhangquan.project.system.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zhangquan.project.system.entity.SysUser;
import com.zhangquan.project.system.service.ISysUserService;

/**
 * @author zhang quan
 * @date 2020年4月7日 上午11:59:00
 */
@RestController
@RequestMapping("/system/user")
public class SysUserController {
	@Autowired
	private ISysUserService userService;
	
	@PostMapping()
	public String add(@RequestBody SysUser sysUser) {
		userService.insertUser(sysUser);
		return "1";		
	}
	
	@DeleteMapping("/{ids}")
	public String remove(@PathVariable Integer[] ids) {
		userService.deleteUserByIds(ids);
		return "2";		
	}
	
	@PutMapping
	public String update(@RequestBody SysUser sysUser) {
		userService.updateUser(sysUser);
		return "3";		
	}
	
	@GetMapping
	public String list(SysUser sysUser) {
		List<SysUser> list = userService.selectUserList(sysUser);
		return list.toString();		
	}
}
